Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Add coverage target in Makefile for coverage reporting #71

Merged
merged 14 commits into from
Jun 1, 2018
Merged

Conversation

shin-
Copy link
Contributor

@shin- shin- commented May 1, 2018

No description provided.

#!/bin/sh

# This script is a proxy that injects the required test flags and strips out test output
# It allows us to use a coverage-enabled binary for e2e tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a script for this? Can't it be done from the Makefile?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do; the script isn't called by the Makefile directly, but is invoked by the e2e test suite as if it was the actual docker-app binary.

More details on why we're doing things this way if you're curious:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks.

.gitignore Outdated
@@ -1,4 +1,5 @@
*.tar.gz
*.dockerapp
_build/
codecoverage/*.out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the output be moved into _build? This way all build intermediate files would be gathered in there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I can certainly do that.

@mat007
Copy link
Contributor

mat007 commented May 2, 2018

You seem to have pushed the coverage branch to docker/lunchbox instead of shin-/lunchbox, is it on purpose?

@shin-
Copy link
Contributor Author

shin- commented May 2, 2018

You seem to have pushed the coverage branch to docker/lunchbox instead of shin-/lunchbox, is it on purpose?

I got into the habit of doing that because the open source Jenkins would often ignore my PRs when submitted from my fork. I'll switch to shin-/lunchbox in the future.

@shin- shin- force-pushed the coverage branch 13 times, most recently from 9b4460d to be08a48 Compare May 3, 2018 00:18
Jenkinsfile Outdated
sh 'make ci-coverage'
archiveArtifacts 'cov/all.out'
archiveArtifacts 'cov/coverage.html'
sh 'curl -s https://codecov.io/bash | bash -s - -t 0b5323a7-aa90-4855-95ad-c859a917d611 -f cov/all.out -K'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the codecov token here for the time being but ideally this would be a build variable in Jenkins or something - @mat007 would you be able to help with this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll have a look.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I just realized this is actually uploading the reports to codecov…
So we don't really need to archive any artifacts nor copy files out of the container, do we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes down to what people expect out of this and how we'd like to leverage the results. If we're okay with being reliant on codecov to produce our report then we can skip the archiving.

OTOH, I'm ok with the extra ~40kB and 2 seconds of processing if it gives us more options.

Jenkinsfile Outdated
steps {
dir('src/github.com/docker/lunchbox') {
checkout scm
sh 'ls -la'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left over from debugging?

Copy link
Contributor

@mat007 mat007 May 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw the ones I left by mistake lines 68, 81 and 94, would you mind removing them as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Jenkinsfile Outdated
checkout scm
sh 'ls -la'
sh 'make ci-coverage'
archiveArtifacts 'cov/all.out'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all.out as an artifact?

Makefile Outdated
ci-coverage:
docker build --target=build -t $(IMAGE_NAME)-cov:$(TAG) $(IMAGE_BUILD_ARGS) .
docker run --label $(COV_LABEL) $(IMAGE_NAME)-cov:$(TAG) make COMMIT=$(TAG) TAG=$(COMMIT) coverage
docker cp $$(docker ps -aql --filter label=$(COV_LABEL)):$(PKG_PATH)/_build/cov/ ./cov
Copy link
Contributor

@mat007 mat007 May 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ./cov creates a folder out of _build when running make ci-coverage locally (I know we're not really supposed to but it proves useful as a poor man's building environment which only requires docker and make).
I suppose it all depends on what we want to do with the coverage reports in the end, a tar.gz might not be very useful…
Currently the generated HTML does not display well as an artifact on Jenkins, see https://ci.baguette.docker.paris/job/lunchbox/view/change-requests/job/PR-71/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, one would have to download the HTML file to view it correctly I imagine.

Jenkinsfile Outdated
agent {
label 'gcp-linux-worker-0'
}
steps {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, if I have the secret configured correctly on the Jenkins side, here you only need to add

                    environment {
                        CODECOV_TOKEN = credentials('jenkins-codeconv-token')
                    }

and then remove the -t flag below and that should be it!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Side note: It looks like I'm not authorized to access that page)

@shin-
Copy link
Contributor Author

shin- commented May 3, 2018

To tie up the threads on the artifacts discussion: I kept things broad for the time being so we can weigh our options. If we feel some are redundant or seldom useful, I'm happy to remove them.

Jenkinsfile Outdated
@@ -44,7 +44,7 @@ pipeline {
parallel {
stage("Coverage report") {
environment {
CODECOV_TOKEN = credentials('jenkins-codecov-token')
CODECOV_TOKEN = credentials('jenkins-codeconv-token')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, sorry, I'll fix that right away…

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, fixed, you can remove the last commit, sorry about that!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@shin- shin- force-pushed the coverage branch 2 times, most recently from d7ba3a8 to dfa4d2e Compare May 3, 2018 19:34
@mat007
Copy link
Contributor

mat007 commented May 3, 2018

@chris-crone any opinion about how we might want to use the coverage report data?

@shin- shin- changed the title [WIP] Add coverage target in Makefile for coverage reporting Add coverage target in Makefile for coverage reporting May 3, 2018
@shin-
Copy link
Contributor Author

shin- commented May 29, 2018

Rebased + fixed some issues with the script uncovered by the new e2e tests

@codecov
Copy link

codecov bot commented May 29, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@133bfaa). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #71   +/-   ##
=========================================
  Coverage          ?   39.57%           
=========================================
  Files             ?       40           
  Lines             ?     2332           
  Branches          ?        0           
=========================================
  Hits              ?      923           
  Misses            ?     1248           
  Partials          ?      161

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 133bfaa...b205e55. Read the comment docs.

@vdemeester
Copy link
Contributor

Something to take into account on https://codecov.io/gh/docker/lunchbox/pull/71/tree though, pretty sure it doesn't cover any packages that has no tests (so 27% is only on packages that have some tests).

Copy link
Contributor

@mat007 mat007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vendoring seems to have issues?

Jenkinsfile Outdated
environment {
CODECOV_TOKEN = credentials('jenkins-codecov-token')
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra blank line

Makefile Outdated
@echo "Running e2e tests (coverage)..."
DOCKERAPP_BINARY=../e2e/coverage-bin $(GO_TEST) -v ./e2e
@echo "Running unit tests (coverage)..."
$(GO_TEST) -cover -test.coverprofile=_build/cov/unit.out $(shell go list ./... | grep -vE '/vendor/|/e2e')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: vendor is actually not listed by go list by default

@@ -20,7 +20,7 @@ type options struct {
}

// flatten flattens a structure: foo.bar.baz -> 'foo.bar.baz'
func flatten(in map[string]interface{}, out map[string]interface{}, prefix string) {
func flatten(in map[string]interface{}, out map[string]string, prefix string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this was intended to change yatee?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that vendoring was broken on master. @mnottale is fixing it after which @shin- may need to rebase

@@ -0,0 +1,27 @@
Copyright (c) 2015 The Polymer Authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of dep are you using? There seems to be a lot of license files being added here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest, AFAICT:

$ dep version
dep:
 version     : v0.4.1
 build date  : 2018-01-24
 git hash    : 37d9ea0a
 go version  : go1.9.1
 go compiler : gc
 platform    : linux/amd64

Copy link
Contributor

@chris-crone chris-crone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, thanks @shin-!

Dockerfile Outdated
git
git \
util-linux \
bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I like to sort these alphabetically so that it's easier to see if something is installed or not

[[override]]
name = "github.com/spf13/pflag"
branch = "master"
source = "github.com/shin-/pflag"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to upstream your changes here so that we don't need to rely on a fork

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR submitted: spf13/pflag#169
I'll keep an eye on it and update if anything happens.

@@ -20,7 +20,7 @@ type options struct {
}

// flatten flattens a structure: foo.bar.baz -> 'foo.bar.baz'
func flatten(in map[string]interface{}, out map[string]interface{}, prefix string) {
func flatten(in map[string]interface{}, out map[string]string, prefix string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that vendoring was broken on master. @mnottale is fixing it after which @shin- may need to rebase

@chris-crone
Copy link
Contributor

@shin- I think you need to rebase on master and then run dep ensure --update github.com/docker/yatee

@mnottale
Copy link
Contributor

No need for the dep ensure, a rebase should take care of that since the operation was done on master.

@shin-
Copy link
Contributor Author

shin- commented Jun 1, 2018

Updated, PTAL!

@chris-crone chris-crone merged commit 9c4e622 into master Jun 1, 2018
@vdemeester vdemeester deleted the coverage branch June 1, 2018 10:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants